﻿using Microsoft.Practices.Unity;
using RockBus.ConfigurationService.Interfaces;
using RockBus.Hosting;
using RockBus.Hosting.Interfaces;
using RockBus.Hosting.Owin;
using RockBus.Initialization.Interfaces;
using RockBus.MonitoringService.Interfaces;
using RockBus.Routing.Interfaces;
using RockBus.Routing.SendPorts;
using RockBus.Services;
using RockBus.Services.WebApi;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace RockBus.Composition
{
    public class MsmqSelfhostedDependencyManager : DependencyManagerBase
    {
        protected override void FillContainer(IUnityContainer container)
        {
            this.FillContainerWithInMemorySubscriptionRespository(container);
            this.FillContainerWithSqlDbMessageRepository(container);
            this.FillContainerWithWebApiDependencies(container);

            container
            .RegisterType<IPersistenceSendPortConfiguration, PersistenceSendPortConfiguration>(new ContainerControlledLifetimeManager())
            .RegisterType<IMessageProcessor, PersistenceSendPort>(InstanceNames.PersistenceSendPort, new ContainerControlledLifetimeManager())
            .RegisterType<IMessageProcessor, DeliverySendPort>(InstanceNames.DeliverySendPort, new ContainerControlledLifetimeManager())
            .RegisterType<IMessageProcessor, InMemoryErrorProcessor>(InstanceNames.ErrorManager, new ContainerControlledLifetimeManager())
            .RegisterType<IInitialization, ServiceHostInitialization>(InstanceNames.ServiceHostInitialization, new ContainerControlledLifetimeManager())
            .RegisterType<IInitialization, OwinHostingInitialization>(InstanceNames.OwinHostingInitialization, new ContainerControlledLifetimeManager())
            ;
        }
    }
}
